<template>
	<view>
		<Navbar></Navbar>
		<view class="u-m-30 u-card-box">
			<view class="u-flex-col u-col-center">

				<u-image width="150rpx" height="150rpx" border-radius="20"
					:src="inviterData.head_img"></u-image>
				<view class="u-font-bold u-font-34">{{inviterData.name}}</view>
				<view class="platform_box">
					<u-parse :html="content"></u-parse>
				</view>
			</view>
			<view class="platform_btn" @click="onGoHome">了解酒局</view>
		</view>
		<view class="u-m-30">
			<view class="u-card-box">
				<view class="u-font-bold u-font-30 u-color-puce u-p-b-20">什么是青创云店</view>
				<view class="u-border-top u-p-t-30 u-p-b-10">
					<u-parse :html="platformContent"></u-parse>
				</view>
			</view>
		</view>
		<view style="height: 100rpx;"></view>
	</view>
</template>

<script>
	import Navbar from '@/components/Navbar.vue'
	import {
		formatContent
	} from '@/utils/index.js'
	import {
		getAgreement,
		userShowBack,
		userInfo
	} from "@/network/api.js"
	export default {
		components: {
			Navbar
		},
		data() {
			return {
				content: '',
				platformContent: '',
				recommendData: {},
				inviterData: {}
			}
		},
		async onLoad(options) {
			await this.$onLaunched
			this.recommendData = JSON.parse(options.data)
			this.onGetUserInfo()
			this.onGetAggreement()
			this.onShowBackUser()
			this.onGetContent()
		},
		methods: {
			onGetAggreement(type) {
				getAgreement({
					type: 15
				}).then(res => {
					this.platformContent = formatContent(res.data.content)
				})
			},
			onGetContent(){
				getAgreement({
					type: 20
				}).then(res => {
					this.content = formatContent(res.data.content)
				})
			},
			onGetUserInfo() {
				userInfo({
					user_id: this.recommendData.inviterId
				}).then(res => {
					this.inviterData = res.data
				})
			},
			onShowBackUser() {
				const params = {
					user_id: uni.getStorageSync("user_id"),
					uuid: this.recommendData.uuid,
					inviterId: this.recommendData.inviterId
				}
				userShowBack(params)
			},
			onGoHome() {
				uni.switchTab({
					url: "/pages/home/home"
				})
			}
		}
	}
</script>

<style scoped>
	.platform_box {
		background: #EFF1F6;
		padding: 20rpx;
		line-height: 1.5;
		border-radius: 20rpx;
		margin-top: 30rpx;
		position: relative;
		max-width: 100%;
	}
	
	.platform_box::before{
		content: "";
		width:0;
		height:0;
		border:20rpx transparent solid;
		border-bottom-color: #EFF1F6;
		border-bottom-width: 20rpx !important;
		position: absolute;
		left: calc(50% - 20rpx);
		top: -40rpx;
	}

	.platform_btn {
		background: linear-gradient(to right, #FB6510 0%, #FB862B 100%);
		color: #fff;
		padding: 18rpx 0;
		border-radius: 50rpx;
		margin-top: 30rpx;
		margin-bottom: 10rpx;
		text-align: center;
	}
</style>